<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE);
require("../requests/library/Requests.php");
require("../simple_html_dom.php");
Requests::register_autoloader();

//变量定义  crontab 每五分钟执行一次
$url = "http://www.douban.com/group/shanghaizufang/discussion?start=0";
$container = []; //存储的待处理文本信息


//开始
$body =  Requests::get($url, [], ['connect_timeout' => 100, 'timeout' => 100])->body; //页面主体信息
$html = str_get_html($body); //dom
$a = $html->find('td.title a');

foreach( $a  as $v )
{
  	$client = new swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);


$client->on("connect", function($cli) use($v) {
	$cli->send($v->href);
});

$client->on("receive", function($cli, $data){
	
});

$client->on("close", function($cli) {
	echo "closed";
});

$client->on("error", function($cli) {
	
});

$client->connect('127.0.0.1', 9501, 0.5);
}
